﻿using System;
using WiMo.Games.Menus;
using WiMo.Games.Drawables;

namespace WiMo.Games.StandardMenus
{
    public class Menu : IMenu
    {
        private IGameEngine _gameEngine;

        public Menu(IGameEngine gameEngine)
        {
            _gameEngine = gameEngine;

            Enabled = true;
            Visible = true;
            MenuComponent = null;
            TextSprite = gameEngine.AssetFactory.CreateText();
            TextSprite.Origin = Origin.TopLeft;
            TextSprite.BackgroundColor = Color.Transparent;
        }

        public int MenuId { get; set; }
        public int MenuIndex { get; set; }
        public bool Enabled { get; set; }
        public bool Visible { get; set; }
        private string _text;
        public string Text
        {
            get{return _text;}
            set
            {
                if (_text != value)
                {
                    TextSprite.Invalidate();
                    TextSprite.DrawInformation = null;
                    TextSprite.Text = value;
                    _text = value;
                }
            }
        }
        public IMenuComponent MenuComponent { get; set; }
        public ISpriteText TextSprite { get; set; }
        public ISpriteShape Background { get; set; }

        public void Render(IDisplay display)
        {
            display.Add(TextSprite);
        }
    }
}
